package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.AttendanceChild;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class AttendanceChildVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "父表id")
    private Integer attendanceId;

    @ApiModelProperty(value = "上班打卡类型：0未打卡1正常2迟到")
    private Integer inClockType;

    @ApiModelProperty(value = "状态：1正常,2异常")
    private Integer status;

    @ApiModelProperty(value = "ip地址")
    private String ip;

    @ApiModelProperty(value = "电脑信息")
    private String mac;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @ApiModelProperty(value = "打卡时间")
    private Date attendanceTime;

    @ApiModelProperty(value = "打卡地址")
    private String address;

    @ApiModelProperty(value = "签到类型：1签到,2签退")
    private Integer clockType;

//    @ApiModelProperty(value = "打卡用户id")
//    private Integer adminId;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static AttendanceChild convert(AttendanceChildVO vo) {
        AttendanceChild entity = new AttendanceChild();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<AttendanceChild> convertList(List<AttendanceChildVO> list) {
        List<AttendanceChild> resultList = new ArrayList<>();
        for (AttendanceChildVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
